package jdbc;

import java.sql.*;

public class Orcale_JDBCTest {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //1、加载驱动
        Class.forName("oracle.jdbc.driver.OracleDriver");
        //2、建立连接
        Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
        //3、测试连接是否成功
        System.out.println(connection);
        //4、定义SQL语句
        String sql = "select * from emp";
        //5、准备静态处理块对象
        Statement statement = connection.createStatement();
//        ResultSet resultSet = statement.executeQuery(sql);
        statement.execute(sql);
        ResultSet resultSet = statement.getResultSet();
        while(resultSet.next()){
            int anInt = resultSet.getInt(1);
            System.out.println(anInt);
            String ename = resultSet.getString("ename");
            System.out.println(ename);
        }
        statement.close();
        connection.close();

    }

}
